<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{$site.name|htmlentities}</title>
    <link rel="stylesheet" href="__CDN__/assets/salary/css/all.min.css">
    <script type="text/javascript" src="__CDN__/assets/libs/jquery/dist/jquery.min.js"></script>
    <script type="text/javascript" src="__CDN__/assets/js/layer/layer.js"></script>
    <style>
        * {margin:0;padding:0;box-sizing:border-box;}
body {height:100vh;display:flex;justify-content:center;align-items:center;background:url('__CDN__/assets/salary/img/01.jpg') no-repeat center center;background-size:cover;font-family:"Microsoft YaHei",sans-serif;}
.container {width:1000px;height:500px;background:rgba(255,255,255,0.6);border-radius:30px;display:flex;box-shadow:0 0 15px rgba(30,83,163,0.4);position:relative;overflow:hidden;backdrop-filter:blur(5px);}
.left-section {width:40%;padding:40px;display:flex;flex-direction:column;align-items:flex-start;z-index:2;}
.logo {width:120px;margin-bottom:30px;}
.title {font-size:26px;color:#2b61b7;margin-bottom:20px;font-weight:bold;}
.form-wrapper {width:85%;}
.form-group {margin-bottom:15px;position:relative;}
.form-group i {position:absolute;left:12px;top:50%;transform:translateY(-50%);color:#2b61b7;z-index:1;}
.form-group input {width:100%;padding:12px 15px 12px 40px;border:1px solid rgba(230,230,230,0.8);border-radius:8px;font-size:15px;background:rgba(255,255,255,0.9);transition:all 0.3s ease;}
.form-group input::placeholder {color:#666;}
.form-group input:focus {outline:none;border-color:#2b61b7;box-shadow:0 0 0 2px rgba(74,105,255,0.1);background:rgba(255,255,255,1);}
.submit-btn {background:#2b61b7;color:white;border:none;padding:12px 0;border-radius:8px;cursor:pointer;font-size:16px;width:100%;transition:background 0.3s;}
.submit-btn:hover {background:#3451DB;}
.right-section {position:absolute;right:0;top:0;width:60%;height:100%;z-index:1;}
.right-section img {width:100%;height:100%;object-fit:cover;}
@media (max-width:768px) {body {align-items:flex-start;padding-top:40px;position:relative;min-height:100vh;}
body::after {content:'';position:fixed;bottom:0;right:0;width:100%;height:40%;background:url('__CDN__/assets/salary/img/nbg.png') no-repeat bottom right;background-size:contain;z-index:0;opacity:0.8;}
.container {width:90%;min-height:auto;background:none;box-shadow:none;backdrop-filter:none;}
.left-section {width:100%;padding:20px;align-items:center;}
.logo {width:100px;margin-bottom:40px;}
.form-wrapper {width:100%;max-width:320px;position:relative;z-index:2;}
.form-group input {background:rgba(255,255,255,0.9);}
.right-section {display:none;}
}

    </style>
</head>
<body>
    <div class="container">
        <div class="left-section">
            <img src="__CDN__/assets/salary/img/logo1.png" alt="Logo" class="logo">
            <h1 class="title">工资查询系统</h1>
            <div class="form-wrapper">
                <form id="salaryForm">
                    <div class="form-group">
                        <i class="fas fa-user"></i>
                        <input type="text" id="name" name="name" placeholder="请输入用户名" required>
                    </div>
                    <div class="form-group">
                        <i class="fas fa-id-card"></i>
                        <input type="text" id="idcard" name="idcard" placeholder="请输入身份证号码" required>
                    </div>

                    <!--新增验证码-->
                    <style>
                        .phone-group, .verify-group {
                        position: relative;
                    }
                    .verify-btn {
                        position: absolute;
                        right: 5px;
                        top: 50%;
                        transform: translateY(-50%);
                        background: #2b61b7;
                        color: white;
                        border: none;
                        padding: 8px 12px;
                        border-radius: 4px;
                        font-size: 14px;
                        cursor: pointer;
                        z-index: 2;
                    }
                    .verify-btn:disabled {
                        background: #ccc;
                        cursor: not-allowed;
                    }
                    .verify-group input {
                        padding-right: 110px;
                    }
                    </style>
                    <div class="form-group phone-group">
                        <i class="fas fa-mobile-alt"></i>
                        <input type="tel" id="phone" name="phone" placeholder="请输入手机号码" required>
                    </div>
                    <div class="form-group verify-group">
                        <i class="fas fa-key"></i>
                        <input type="text" id="code" name="code" placeholder="请输入验证码" required>
                        <button type="button" class="verify-btn" id="verifyBtn">获取验证码</button>
                    </div>


                    <button id="submit" type="button" class="submit-btn">
                        <i class="fas fa-search"></i> 查询
                    </button>
                </form>
            </div>
        </div>
        <div class="right-section">
            <img src="__CDN__/assets/salary/img/nbg.png" alt="Decoration">
        </div>
    </div>
    <script>
    $(function() {

        const verifyBtn = document.getElementById('verifyBtn');
        let counting = false;
        let countDown = 60;

        verifyBtn.addEventListener('click', function() {
            if (counting) return;

            // 验证手机号
            const phoneInput = document.querySelector('input[type="tel"]');
            const phoneNumber = phoneInput.value.trim();
            if (!/^1[3-9]\d{9}$/.test(phoneNumber)) {
                layer.msg('请输入正确的手机号码');
                return;
            }

            counting = true;
            verifyBtn.classList.add('counting');

            let timer = setInterval(() => {
                countDown--;
                verifyBtn.textContent = `${countDown}秒后重试`;

                if (countDown <= 0) {
                    clearInterval(timer);
                    verifyBtn.textContent = '获取验证码';
                    verifyBtn.classList.remove('counting');
                    counting = false;
                    countDown = 60;
                }
            }, 1000);


            $.post("{:url('index/sendcode')}", {mobile:phoneNumber}, function(res) {
                layer.msg(res.msg);
            }, 'json');

        });

        var status = 1;
        $('#submit').click(function() {
            var name = $('#name').val();
            var idcard = $('#idcard').val();
            var phone = $('#phone').val();
            var code = $('#code').val();

            if (name == '') {
                layer.msg('请输入用户名');
                return false;
            }

            if (idcard == '') {
                layer.msg('请输入身份证号码');
                return false;
            }

            if (phone == '') {
                layer.msg('请输入手机号码');
                return false;
            }

            if (code == '') {
                layer.msg('请输入验证码');
                return false;
            }

            if (status == 0) {
                return false;
            }
            status = 0;

            $.post("{:url('index/index')}", {name:name, idcard:idcard, mobile:phone, code:code}, function(res) {
                status = 1;
                if (res.code == 1) {
                    layer.msg(res.msg);
                    return false;
                } else if (res.code == 0) {
                    window.location.href = "{:url('index/salary')}";
                }
            }, 'json');
        });
    });

    </script>
</body>
</html>